package com.xwj.seckill.controller;

import com.xwj.common.dto.BaseResponse;
import com.xwj.seckill.dto.BookRobDto;
import com.xwj.seckill.service.BookRobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 书籍抢购控制层
 * @author xwj
 * @date 2020/5/6
 */
@RestController
@RequestMapping("/book/seckill/")
public class BookSeckillController {
    @Autowired
    private BookRobService bookRobService;

    @GetMapping("/robWithNoLock")
    public BaseResponse robWithNoLock(@Validated BookRobDto dto) {
        return bookRobService.robWithNoLock(dto);
    }

    @GetMapping("/robWithZookeeperLock")
    public BaseResponse robWithZookeeperLock(@Validated BookRobDto dto) {
        return bookRobService.robWithZookeeperLock(dto);
    }

    @GetMapping("/robWithRedisLock")
    public BaseResponse robWithRedisLock(@Validated BookRobDto dto) {
        return bookRobService.robWithRedisLock(dto);
    }

    @GetMapping("/robWithAopRedisLock")
    public BaseResponse robWithAopRedisLock(@Validated BookRobDto dto) {
        return bookRobService.robWithAopRedisLock(dto);
    }

    @GetMapping("/robWithAopZkLock")
    public BaseResponse robWithAopZkLock(@Validated BookRobDto dto) {
        return bookRobService.robWithAopZkLock(dto);
    }

    @GetMapping("/robWithRedissonLock")
    public BaseResponse robWithRedissonLock(@Validated BookRobDto dto) {
        return bookRobService.robWithRedissonLock(dto);
    }
}
